let pageParams = (ctx, tools) => {
    let whichPage = ctx.request.body.whichPage
    let user = ctx.user
    let cs = {
        contact: {
            fileName: '客户列表',
            order: ' order by areaId desc ',
            quick: 'name',
            columns: [
                {field: 'areaName', title: '线路', width: 100, idField: 'areaId', excel: true, com: 'JSelect',props: { sql: `select id,name from area where tenantId=${user.tenantId} ` },sop: '='},
                {field: 'categoryName', title: '客户分类', width: 120,excel: true,idField:'categoryId',com: 'JSelect',sop:'=',props: { sql: `select id,name from contact_cat where tenantId=${user.tenantId} ` }},
                {field: 'salesName', title: '业务员', width: 100,excel: true,com: 'JSelect',sop: '=', idField: 'salesId', props: {sql:  `select id,name from admin where tenantId=${user.tenantId}  and isDel=0 `}},
                {field: 'name', title: '客户名称', width: 300,excel: true,com: 'el-input',sop:'include', required: true, props:{clearable: true} },
                {field: 'linkName', title: '联系人', width: 100,excel: true,com: 'el-input',sop:'include',   },
                {field: 'linkMobile', title: '手机', width: 100,excel: true,com: 'el-input',sop:'include',  },
                {field: 'address', title: '定位地址', width: 260,excel: true,com: 'el-input', required: true, },
                {field: 'remark', title: '备注', width: 120,excel: true,com: 'el-input',sop:'include'  },
                {field: 'longitude', title: '经度', width: 100,type: 'hidden',  },
                {field: 'latitude', title: '纬度', width: 100, type: 'hidden', },
            ]
        },
        contactMy: {
            fileName: '我的客户',
            order: ' order by id desc ',
            quick: 'name',
            sql: `select * from (select a.id,a.categoryId,cc.name categoryName,a.areaId,a.salesId,a.name,a.isProvider,a.isCustomer,
                      a.linkMobile,a.linkName,a.address,a.payType,a.remark,b.name salesName,c.name areaName from contact a left join admin b on a.salesId=b.id
                 left join area c on a.areaId=c.id left join contact_cat cc on a.categoryId=cc.id
                 where a.tenantId=${user.tenantId} and a.isDel=0) a where 1=1 `,
            columns: [
                {type: 'seq', width: 50, excel: true, },
                {field: 'areaName', title: '线路', width: 100, excel: true, sortable: true,filter: true },
                {field: 'categoryName', title: '客户分类', width: 120,excel: true,filter: true , sortable: true},
                {field: 'salesName', title: '业务员', width: 120,excel: true,filter: true, sortable: true },
                {field: 'name', title: '客户名称', width: 300,excel: true, filter: true, sortable: true },
                {field: 'linkName', title: '联系人', width: 120,excel: true, },
                {field: 'linkMobile', title: '电话', width: 150,excel: true,  },
                {field: 'address', title: '地址', width: 260,excel: true, },
                {field: 'longitude', title: '经度', width: 100, visible: false  },
                {field: 'latitude', title: '纬度', width: 100, visible: false, },
                {field: 'payType', title: '结算周期', width: 120,excel: true, align: 'center' },
                {field: 'remark', title: '备注', width: 120,excel: true, },
                {
                    field: 'op', title: '操作', width: 120,fixed: 'right', slots: {default: 'op'},
                    btns: [
                        {label: '编辑',click: (row) => {
                            JOpen({
                                whichPage: 'contactMy',
                                refresh: _this.refresh,
                                initData: row
                            })
                        }},
                        {label: '删除',confirm: {msg: '确定删除 ？'},click: (row) => {
                                _tool.post('contact/delById', {
                                    ids: [row.id]
                                }).then(ret => {
                                    if (ret.stat) {
                                        _this.getList()
                                    }
                                })
                        }},
                    ]
                },
            ],
            search: {
                rule: [
                    {field: 'areaId', title: '线路',  type: 'JSelect',props: { cat: 'area' },op: '=$'},
                    {field: 'categoryId', title: '客户分类', type: 'JSelect',op:'=$',props: { cat: 'contactCat' }},
                    {field: 'salesId', title: '业务员',type: 'JSelect',op: '=$',  props: {cat: 'admin'}},
                    {field: 'name', title: '客户名称', quick: true, type: 'input',op:"  like '%$%' ",  props:{clearable: true} },
                    {field: 'linkName', title: '联系人', type: 'input',op:"  like '%$%' ",   },
                    {field: 'linkMobile', title: '电话', type: 'input',op: "  like '%$%' "  },
                    {field: 'address', title: '地址',quick: true, type: 'input',   },
                    {
                        field: 'payType', title: '结算周期',  type: 'JSelect' ,op:"='$'",props:{
                            list:[
                                {id: '现结', name: '现结'},
                                {id: '月结', name: '月结'},
                                {id: '滚单', name: '滚单'},
                            ]
                        }
                    },
                    {field: 'remark', title: '备注', type: 'input',op: "  like '%$%' " },
                    { field: 'isProvider', title: '供应商', type: 'el-checkbox', op:'=$', props: {clearable: true,trueLabel:1,falseLabel: 0}, col:{span: 12},value: 0 },
                    { field: 'isCustomer', title: '终端', type: 'el-checkbox', op:'=$', props: {clearable: true,trueLabel:1,falseLabel: 0}, col:{span: 12},value: 0 },
                ]
            },
            form: {
                mod: 'contact',
                width: 600,
                height: 350,
                rule: [
                    {field: 'id', type: 'hidden'},
                    {
                        field: 'areaId', title: '线路', type:'JSelect', props:{cat: 'area'}, col: {span: 12}
                    },
                    {
                        field: 'categoryId', title: '客户分类', type:'JSelect', props:{cat: 'contactCat'}, col: {span: 12}
                    },
                    {
                        field: 'salesId', title: '业务员', type:'JSelect', props:{cat: 'admin'}, col: {span: 12}
                    },
                    {
                        field: 'payType', title: '结算周期', type:'JSelect', props:{list:[
                                {id: '现结', name: '现结'},
                                {id: '月结', name: '月结'},
                                {id: '滚单', name: '滚单'},
                            ]}, col: {span: 12}
                    },
                    { field: 'name', title: '客户名称', type: 'input', effect: {required: true}, props: {clearable: true} },
                    { field: 'address', title: '地址', type: 'input', effect: {required: true}, props: {clearable: true} },
                    { field: 'linkName', title: '联系人', type: 'input', props: {clearable: true} },
                    { field: 'linkMobile', title: '电话', type: 'input',  props: {clearable: true} },
                    { field: 'isProvider', title: '供应商', type: 'el-checkbox',  props: {clearable: true,trueLabel:1,falseLabel: 0}, col:{span: 12},value: 0 },
                    { field: 'isCustomer', title: '终端', type: 'el-checkbox',  props: {clearable: true,trueLabel:1,falseLabel: 0}, col:{span: 12},value: 1 },

                ]
            }
        },
        contactCat: {
            fileName: '客户分类',
            order: ' order by id desc ',
            quick: 'name', // 快速搜索的field
            sql: `select * from contact_cat where tenantId=${user.tenantId} `,
            columns: [
                {type: 'seq', width: 60 },
                {field: 'name', title: '分类名称', excel: true, width: 300},
                {
                    field: 'op', title: '操作', width: 120,fixed: 'right', slots: {default: 'op'},
                    btns: [
                        {label: '编辑',click: (row) => {
                                JOpen({
                                    whichPage: 'contactCat',
                                    refresh: _this.refresh,
                                    initData: row
                                })
                            }},
                        {label: '删除',confirm: {msg: '确定删除 ？'},click: (row) => {
                                _tool.post('contactCat/delById', {
                                    ids: [row.id]
                                }).then(ret => {
                                    if (ret.stat) {
                                        _this.getList()
                                    }
                                })
                            }},
                    ]
                },
            ],
            search: {
                rule: [
                    {field: 'name', title: '分类名称', op: " like '%$%' "}
                ]
            },
            form: {
                mod: 'contactCat',
                rule: [
                    {field: 'id', type: 'hidden'},
                    {field: 'name', title: '分类名称',  }
                ]
            }
        },
        jpgl: {
            fileName: '奖品管理',
            order: ' order by id desc ',
            quick: 'name', // 快速搜索的field
            columns: [
                {field: 'name', title: '奖品名称', excel: true, },
                {field: 'price', title: '等值金额', excel: true, },
                {field: 'remark', title: '备注', excel: true, },
            ]
        },
        role: {
            fileName: '角色管理',
            order: ' order by id desc ',
            quick: 'name', // 快速搜索的field
            columns: [
                {field: 'name', title: '奖品名称', excel: true, },
            ]
        },
        yhgl: {
            fileName: '用户管理',
            order: ' order by id desc ',
            quick: 'name', // 快速搜索的field
            columns: [
                {field: 'username', title: '用户名',excel: true,},
                {field: 'name', title: '姓名',excel: true,},
                {field: 'mobile', title: '手机号',excel: true,},
                {field: 'deptName', title: '部门', excel: true,},
                {field: 'roleName', title: '角色', excel: true,},
            ]
        },
        bfMx: {
            fileName: '拜访明细',
            quick: 'name', // 快速搜索的field
            columns: [
                {field: 'billDate', title: '拜访时间', excel: true},
                {field: 'salesName', title: '业务员', excel: true},
                {field: 'buName', title: '客户', excel: true},
                {field: 'address', title: '定位', excel: true},
                {field: 'arrived', title: '到店', excel: true},
                {field: 'leftTime', title: '离店', excel: true},
                {field: 'durationStr', title: '用时', excel: true},
                {field: 'lastDistance', title: '距上点(米)', excel: true},
            ]
        },
        dept: {
            fileName: '部门管理',
            columns: [
                {type: 'seq', width: 50},
                {field: 'name', title: '部门名称', width: 150,treeNode: true, op: " ='%$%' ",excel: true},
                {field: 'phone', title: '部门电话', width: 150, op: " like '%$%' ",excel: true},
                {
                    title: '操作', slots:{default: 'op'}, width: 80,fixed: 'right',
                    btns: [
                        {
                            label: '编辑', click: (row, rowIndex) => {
                                JOpen({
                                    whichPage: 'dept',
                                    refresh: _this.refresh,
                                    initData: row
                                })
                            }
                        },
                        {
                            label: '删除', confirm: {msg: '确定删除 ？'},
                            click: (row, rowIndex) => {
                                _tool.post('dept/delById', {
                                    ids: [row.id]
                                }).then(ret => {
                                    if (ret.stat) {
                                        _this.getList()
                                    }
                                })
                            }
                        },
                    ]
                },
            ],
            sql: `select id,name, phone from dept where tenantId=${user.tenantId} `,
            order: ' order by id desc ',
            search: {
                rule: [
                    {field: 'name', title: '部门名称',quick: true,op: ` like '%$%'` },
                ]
            },
            form: {
                mod: 'dept',
                rule: [
                    {field: 'id', type: 'hidden' },
                    {field: 'name', title: '部门名称', effect: {required: true} },
                    {field: 'phone', title: '部门电话',  },
                ]
            }
        },
        customerbills: {
            fileName: '往来对账单',
            allowPage: false,
            columns: [
                {type: 'seq', width: 50},
                {field: 'name', title: '部门名称', width: 150,treeNode: true, op: " ='%$%' ",excel: true},
                {field: 'manName', title: '负责人', width: 80, op: " like '%$%' ",excel: true},
                {field: 'phone', title: '部门电话', width: 80, op: " like '%$%' ",excel: true},
            ],
            sql: `select * from (
                    select a.*,b.name manName from dept a left join admin b on a.manId=b.id 
                    where a.tenantId=${user.tenantId} and a.isDel=0
                  ) a where 1=1  `,
            order: ' order by id desc ',
            form: {
                rule: [
                    {field: 'name', title: '部门名称', effect: {required: true} },
                    {field: 'manName', title: '负责人',  },
                    {field: 'phone', title: '部门电话',  },
                ]
            }
        },
        tenant: {
            fileName: '租户管理',
            allowPage: false,
            columns: [
                {type: 'seq', width: 50},
                {field: 'name', title: '部门名称', width: 150,treeNode: true, op: " ='%$%' ",excel: true},
                {field: 'manName', title: '负责人', width: 80, op: " like '%$%' ",excel: true},
                {field: 'phone', title: '部门电话', width: 80, op: " like '%$%' ",excel: true},
            ],
            sql: `select * from (
                    select a.*,b.name manName from dept a left join admin b on a.manId=b.id 
                    where a.tenantId=${user.tenantId} and a.isDel=0
                  ) a where 1=1  `,
            order: ' order by id desc ',
            form: {
                mod: 'tenant',
                rule: [
                    {field: 'id', type: 'hidden'},
                    {field: 'name', title: '租户名称', effect: {required: true},props: {clearable: true} },
                    {field: 'mobile', title: '手机号',props: {clearable: true},  },
                ]
            }
        },
        goods: {
            fileName: '商品管理',
            allowPage: true,
            columns: [
                {type: 'seq', width: 50},
                {field: 'name', title: '商品名称', width: 350,treeNode: true, op: " ='%$%' ",excel: true},
                {field: 'categoryName', title: '分类', width: 150, op: " =$ ",excel: true,align: 'center',sortable: true},
                {field: 'spec', title: '规格', width: 80, op: " ='$' ",excel: true,align: 'center'},
                {field: 'unit1', title: '大单位', width: 80, op: " ='$' ",excel: true,align: 'center'},
                {field: 'unit2', title: '小单位', width: 80, op: " like '%$%' ",excel: true,align: 'center'},
{field: 'barCode', title: '大条码', width: 80, op: " ='$' ",excel: true,align: 'center'},
{field: 'barCode1', title: '小条码', width: 80, op: " ='$' ",excel: true,align: 'center'},
                {field: 'price1', title: '采购价', width: 80, op: " like '%$%' ",excel: true,align: 'right'},
                {field: 'price2', title: '零售价', width: 80, op: " like '%$%' ",excel: true,align: 'right'},
                {field: 'op', title: '操作', width: 120,fixed: 'right', slots: {default: 'op'}, btns: [
                        {label: '编辑',click: (row) => {
                                JOpen({
                                    title: '商品',
                                    des: '大单位 = 小单位 * 规格',
                                    whichPage: 'goods',
                                    refresh: _this.refresh,
                                    initData: row,
                                })
                            }},
                        {label: '删除',confirm: {msg: '确定删除 ？'},click: (row) => {
                                _tool.post('page/del', {
                                    whichPage: 'goods',
                                    ids: [row.id]
                                }).then(ret => {
                                    if (ret.stat) {
                                        _this.getList()
                                    }
                                })
                            }},
                    ]},
            ],
            sql: `select * from (
                    select a.id,a.tenantId,a.name,categoryId,a.unit1,a.unit2,a.price1,a.price2,a.spec,b.name categoryName,a.barCode,a.barCode1 from goods a left join goods_cat b on a.categoryId=b.id
                  ) a where a.tenantId=${user.tenantId}  `,
            order: ' order by id desc ',
            search: {
                rule: [
                    {field: 'name', title: '商品名称', width: 150, op: " like '%$%' ",quick: true ,props: {clearable: true}},
                    {title: '分类', field: 'categoryId', type: 'JSelect', op: " =$ ",props: {cat: 'goodsCat', clearable: true}},
                ]
            },
            form: {
                mod: 'goods',
                width: 500,
                height: 500,
                rule: [
                    {type: 'hidden', field: 'id'},
                    {title: '分类', field: 'categoryId', type: 'JSelect',effect: {required: true}, props: {cat: 'goodsCat'}},
                    {title: '名称', field: 'name', effect: {required: true}},
                    {title: '规格', field: 'spec',type: 'vxe-input', style: 'width:100%;',effect: {required: true},props:{type: 'integer',size: 'mini'}},
                    {title: '大单位', field: 'unit1',type: 'JSelect', effect: {required: true},props:{cat: 'unit'}},
                    {title: '小单位', field: 'unit2',type: 'JSelect', props:{cat: 'unit'}},
 	    {title: '大条码', field: 'barCode' },
 	    {title: '小条码', field: 'barCode1' },
                    {title: '大单位成本',type:'vxe-input', field: 'price1',style: 'width:100%;',props:{type: 'float', precision: 2,size: 'mini'} },
                    {title: '大单位零售价',type:'vxe-input', field: 'price2',style: 'width:100%;', props:{type: 'float', precision: 2,size: 'mini'}}
                ]
            }
        },
        users: {
            fileName: '用户管理',
            allowPage: true,
            columns: [
                {type: 'seq', width: 50},
                {field: 'username', title: '用户名', width: 150, op: " ='%$%' ",excel: true},
                {field: 'name', title: '姓名', width: 200, op: " ='%$%' ",excel: true},
                {field: 'deptName', title: '部门', width: 150, op: " ='%$%' ",excel: true},
                {field: 'roleName', title: '角色', width: 150, op: " ='$' ",excel: true,align: 'center'},
                {field: 'mobile', title: '手机', width: 150, op: " like '%$%' ",excel: true,align: 'left'},
                {field: 'op', title: '操作', width: 200,fixed: 'right', slots: {default: 'op'}, btns: [
                        {label: '编辑',click: (row) => {
                                JOpen({
                                    title: '用户',
                                    whichPage: 'users',
                                    refresh: _this.refresh,
                                    initData: row,
                                    url: 'user/save'
                                })
                            }},
                        {label: '修改密码',click: (row) => {
                                _this.$emit('setPwd', row)
                            }},
                        {label: '删除',confirm: {msg: '确定删除 ？'},click: (row) => {
                                _tool.post('user/del', {
                                    ids: [row.id]
                                }).then(ret => {
                                    if (ret.stat) {
                                        _this.getList()
                                    }
                                })
                            }},
                    ]},
            ],
            sql: ` select * from (select a.id,a.name,a.username,a.roleId,a.deptId,b.name deptName,
                c.name roleName,a.mobile from admin a left  join dept b on a.deptId=b.id left join role c on 
                a.roleId=c.id where a.tenantId=${user.tenantId} and a.isDel=0) a where 1=1 `,
            order: ' order by id desc ',
            search: {
                rule: [
                    {field: 'username', title: '用户名', width: 150, op: " like '%$%' ",quick: true ,props: {clearable: true}},
                    {field: 'name', title: '姓名', width: 150, op: " like '%$%' ",quick: true ,props: {clearable: true}},
                    {field: 'deptId', title: '部门', width: 150, op: " =$ ",type: 'JSelect' ,props: {cat: 'dept'}},
                    {field: 'roleId', title: '角色', width: 150, op: " =$ ",type: 'JSelect' ,props: {cat: 'role'}},
                ]
            },
            form: {
                mod: 'admin',
                width: 500,
                height: 300,
                rule: [
                    {type: 'hidden', field: 'id'},
                    {title: '用户名', field: 'username', },
                    {title: '姓名', field: 'name', effect: {required: true}},
                    {title: '手机', field: 'mobile', },
                    {title: '部门', field: 'deptId', type: 'JSelect', props: {cat: 'dept'}},
                    {title: '角色', field: 'roleId', type: 'JSelect', props: {cat: 'role'}},
                ]
            }
        },
        销售明细: {
            fileName: '销售明细',
            allowPage: true,
            columns: [
                {type: 'seq', width: 50,fixed: 'left'},
                {type: 'checkbox', width: 50,align: 'center',fixed: 'left'},
                {field: 'billDate', title: '票据日期', width: 100, excel: true,sortable: true,filter: true,fixed: 'left'},
                {field: 'billNo', title: '票号', width:120, excel: true,sortable: true,filter: true,canClick: true,fixed: 'left'},
                {field: 'transTypeName', title: '业务类型', width: 100,excel: true,align: 'center',sortable: true,filter: true,fixed: 'left'},
                {field: 'contactCat', title: '客户类型', width: 100,excel: true,sortable: true,filter: true,fixed: 'left'},
                {field: 'buName', title: '客户名称', width: 200,excel: true,sortable: true,filter: true,fixed: 'left'},
                {field: 'categoryName', title: '商品分类', width: 100,excel: true,sortable: true,filter: true},
                {field: 'invName', title: '商品名称', width: 200,excel: true,sortable: true,filter: true},
                {field: 'barCode1', title: '条码', width: 90,excel: true,sortable: true,filter: false},
                {field: 'salesName', title: '业务员', width: 100,excel: true,sortable: true,filter: true},
                {field: 'deliverNames', title: '送货员', width: 100,excel: true,sortable: true,filter: true},
                {field: 'spec', title: '规格', width: 70,excel: true,align: 'center',},
                {field: 'unit', title: '单位', width: 70,excel: true,align: 'center',},
                {field: 'qty', title: '票据数量', width: 90,excel: true,align: 'right',sortable: true},
                {field: 'qtyReal', title: '出库数量', width: 90,excel: true,align: 'right',sortable: true,sum: true},
                {field: 'price', title: '单价', width: 80,excel: true,align: 'right',sortable: true},
                {field: 'assQty', title: '辅助数量', width: 100,excel: true,align: 'right',sum: true},
                {field: 'send', title: '赠品', width: 100,excel: true,align: 'center',filter: true,sortable: true},
                {field: 'amount', title: '票据金额', width: 100,excel: true,align: 'right',sortable: true},
                {field: 'subAmount', title: '应收金额', width: 100,excel: true,align: 'right',sortable: true,sum: true},
                {field: 'remark', title: '备注', width: 120,excel: true,sortable: true,filter: true},
                {field: 'skDate', title: '收款时间', width: 100,excel: true,sortable: true,filter: true},
            ],
            sql: ` `,
            order: ' order by id desc ',
            search: {
                rule: [
                    {field: 'beginDate', title: '开始日期', width: 150, op: " ='$' ",type: 'JPicker', props: {clearable: true},value: tools.getDay('', -15)},
                    {field: 'endDate', title: '结束日期', width: 150, op: " ='$' ",type: 'JPicker',props: {clearable: true},value: tools.getDay()},
                    {field: 'billNo', title: '票号', width: 150, op: " like '%$%' ", props: {clearable: true}},
                    {field: 'transType', title: '业务类型', width: 150, op: " ='$' ",type: 'JSelect',props: {clearable: true, list:[{id: 150601,name: '销售单'},{id: 150602,name: '销售退货单'},{id: 150603,name: '销售换货单'},]}},
                    {field: 'contactCatId', title: '客户分类', width: 150, op: " ='$' ",type: 'JSelect',props: {clearable: true, cat: 'contactCat'}},
                    {field: 'buId', title: '客户名称', width: 150, op: " ='$' ",type: 'JSelect',props: {clearable: true, cat: 'contact'}},
                    {field: 'goodsCatId', title: '商品分类', width: 150, op: " ='$' ",type: 'JSelect',props: {clearable: true, cat: 'goodsCat'}},
                    {field: 'invId', title: '商品名称', width: 150, op: " ='$' ",type: 'JSelect',props: {clearable: true, cat: 'goods'}},
                    {field: 'salesId', title: '销售员', width: 150, op: " ='$' ",type: 'JSelect',props: {clearable: true, cat: 'admin'}},
                    {field: 'deliverId', title: '送货员', width: 150, op: " ='$' ",type: 'JSelect',props: {clearable: true, cat: 'admin'}},
                    {field: 'remark', title: '备注', width: 150, op: " like '%$%' " ,props: {clearable: true}},
                ]
            },
            form: {
                rule: []
            }
        },
        对账明细: {
            fileName: '对账明细',
            allowPage: true,
            columns: [
                {type: 'seq', width: 50},
                {field: 'buName', title: '往来单位', width: 100, excel: true,sortable: true,filter: true},
                {field: 'billDate', title: '票据日期', width:120, excel: true,sortable: true,filter: true,canClick: true},
                {field: 'billNo', title: '票号', width: 100,excel: true,align: 'center',sortable: true,filter: true},
                {field: 'billType', title: '类型', width: 100,excel: true,sortable: true,filter: true},
                {field: 'amount', title: '票据金额', width: 200,excel: true,sortable: true,filter: true},
                {field: 'hxAmount', title: '核销金额', width: 100,excel: true,sortable: true,filter: true},
                {field: 'ysAdd', title: '应收增加', width: 200,excel: true,sortable: true,filter: true},
                {field: 'ye', title: '应收余额', width: 100,excel: true,sortable: true,filter: true},
            ],
        },
        其他业务收入: {
            fileName: '其他业务收入',
            allowPage: false,
            sql: `select * from category where tenantId=${user.tenantId} and pid=(select id from category where tenantId=${user.tenantId} and name ='其他业务收入')`,
            columns: [
                {type: 'seq', width: 50},
                {field: 'name', title: '类别名称', width: 300, excel: true,sortable: true,filter: true},
                {
                    field: 'op', title: '操作', width: 120,fixed: 'right', slots: {default: 'op'},
                    btns: [
                        {label: '编辑',click: (row) => {
                                JOpen({
                                    whichPage: '其他业务收入',
                                    url: "category/saveQtsr",
                                    refresh: _this.refresh,
                                    initData: row
                                })
                            }},
                        {label: '删除',confirm: {msg: '确定删除 ？'},click: (row) => {
                                _tool.post('category/delQtsr', {
                                    ids: [row.id]
                                }).then(ret => {
                                    if (ret.stat) {
                                        _this.getList()
                                    }
                                })
                            }},
                    ]
                },
            ],
            search: {
                rule: []
            },
            form: {
                mod: 'category',
                rule: [
                    {field: 'id', type: 'hidden'},
                    { field: 'name', title: '类别名称', type: 'input', effect: {required: true}, props: {clearable: true} },
                ]
            }
        },
        其他业务支出: {
            fileName: '其他业务支出',
            allowPage: false,
            sql: `select * from category where tenantId=${user.tenantId} and pid=(select id from category where tenantId=${user.tenantId} and name ='其他业务支出')`,
            columns: [
                {type: 'seq', width: 50},
                {field: 'name', title: '类别名称', width: 300, excel: true,sortable: true,filter: true},
                {
                    field: 'op', title: '操作', width: 120,fixed: 'right', slots: {default: 'op'},
                    btns: [
                        {label: '编辑',click: (row) => {
                                JOpen({
                                    whichPage: '其他业务支出',
                                    url: "category/saveQtzc",
                                    refresh: _this.refresh,
                                    initData: row
                                })
                            }},
                        {label: '删除',confirm: {msg: '确定删除 ？'},click: (row) => {
                                _tool.post('category/delQtsr', {
                                    ids: [row.id]
                                }).then(ret => {
                                    if (ret.stat) {
                                        _this.getList()
                                    }
                                })
                            }},
                    ]
                },
            ],
            search: {
                rule: []
            },
            form: {
                mod: 'category',
                rule: [
                    {field: 'id', type: 'hidden'},
                    { field: 'name', title: '类别名称', type: 'input', effect: {required: true}, props: {clearable: true} },
                ]
            }
        },
        结算账户: {
            fileName: '结算账户',
            allowPage: false,
            sql: `SELECT * from category where  typeNumber='subject' and tenantId=${user.tenantId} and pid in(SELECT id from category where tenantId=${user.tenantId} and typeNumber='subject' and name = '银行存款')`,
            columns: [
                {type: 'seq', width: 50},
                {field: 'name', title: '账户名称', width: 300, excel: true,sortable: true,filter: true},
                {
                    field: 'op', title: '操作', width: 120,fixed: 'right', slots: {default: 'op'},
                    btns: [
                        {label: '编辑',click: (row) => {
                                JOpen({
                                    whichPage: '结算账户',
                                    url: "category/saveAccount",
                                    refresh: _this.refresh,
                                    initData: row
                                })
                            }},
                        {label: '删除',confirm: {msg: '确定删除 ？'},click: (row) => {
                                _tool.post('category/delAccount', {
                                    ids: [row.id]
                                }).then(ret => {
                                    if (ret.stat) {
                                        _this.getList()
                                    }
                                })
                            }},
                    ]
                },
            ],
            search: {
                rule: []
            },
            form: {
                mod: 'category',
                rule: [
                    {field: 'id', type: 'hidden'},
                    { field: 'name', title: '账户名称', type: 'input', effect: {required: true}, props: {clearable: true} },
                ]
            }
        },
        期初库存: {
            fileName: '期初库存',
            allowPage: false,
            sql: ` SELECT  a.id,a.tenantId,a.locationId,a.locationName,a.invId,a.invName,a.unit,a.qty,a.amount,b.spec,b.unit1,b.unit2,
                           case when a.unit=b.unit1 then concat(a.qty,b.unit1) when a.unit=b.unit2 then concat(a.qty/b.spec,b.unit1, a.qty%b.spec,b.unit2)
                               end assQty  from init_goods a left join goods b on a.invId=b.id where a.tenantId=${user.tenantId}`,
            columns: [
                {type: 'seq', width: 50},
                {field: 'invName', title: '商品名称', width: 300, excel: true,sortable: true,filter: true},
                {field: 'locationName', title: '仓库名称', width: 100, excel: true,sortable: true,filter: true},
                {field: 'spec', title: '规格', width: 80, excel: true,align: 'center'},
                {field: 'unit', title: '单位', width: 80, excel: true,align: 'center'},
                {field: 'qty', title: '期初数量', width: 100, excel: true,sortable: true,align: 'right'},
                {field: 'assQty', title: '辅助数量', width: 100, excel: true,align: 'right'},
                {field: 'amount', title: '期初金额', width: 100, excel: true,sortable: true,align: 'right'},
                {
                    field: 'op', title: '操作', width: 120,fixed: 'right', slots: {default: 'op'},
                    btns: [
                        {label: '编辑',click: (row) => {
                                JOpen({
                                    whichPage: '期初库存',
                                    url: "goods/saveInit",
                                    refresh: _this.refresh,
                                    initData: row
                                })
                            }},
                        {label: '删除',confirm: {msg: '确定删除 ？'},click: (row) => {
                                _tool.post('goods/delInit', {
                                    ids: [row.id]
                                }).then(ret => {
                                    if (ret.stat) {
                                        _this.getList()
                                    }
                                })
                            }},
                    ]
                },
            ],
            search: {
                rule: [
                    {field: 'invName', title: '商品名称', quick: true, type: 'input',op:"  like '%$%' ",  props:{clearable: true} },
                    { field: 'locationId', title: '仓库名称', type: 'JSelect',  props: {clearable: true,cat: 'storage'} },
                ]
            },
            form: {
                mod: 'initGoods',
                rule: [
                    {field: 'id', type: 'hidden'},
                    {
                        field: 'invId', title: '商品名称', type: 'JSelect', effect: {required: true}, props: {clearable: true,cat: 'goods'} ,
                        inject: true,
                        on: {
                            change: (inject, val) => {
                                if(val) {
                                    _tool.post('common/getOne',{sql: `select id,name from storage where tenantId=${_tool.data.getTenantId()}`}).then(ret => {
                                        if(ret.stat) {
                                            let list = [
                                                {id: ret.data.id, name: ret.data.name}
                                            ]
                                            inject.$f.mergeRule('unit',{props:{list: list}})
                                            inject.$f.setValue('locationId', ret.data.id)
                                        }
                                    })
                                    _tool.post('common/getOne',{sql: `select unit1,unit2 from goods where id=${val.id}`}).then(ret => {
                                        if(ret.stat) {
                                            let list = []
                                            if(typeof ret.data.unit1 != 'undefined') {
                                                list.push({
                                                    id: ret.data.unit1,
                                                    name: ret.data.unit1,
                                                })
                                            }
                                            if(typeof ret.data.unit2 != 'undefined') {
                                                list.push({
                                                    id: ret.data.unit2,
                                                    name: ret.data.unit2,
                                                })
                                            }
                                            inject.$f.mergeRule('unit',{props:{list: list}})
                                            if(list.length === 2) {
                                                inject.$f.setValue('unit', list[1].id)
                                            }
                                            if(list.length === 1) {
                                                inject.$f.setValue('unit', list[0].id)
                                            }
                                        }
                                    })
                                }
                                else {
                                    inject.$f.mergeRule('unit',{props:{list: []}})
                                    inject.$f.setValue('unit', null)
                                }
                            }
                        }
                    },
                    { field: 'locationId', title: '仓库名称', type: 'JSelect', effect: {required: true}, props: {clearable: true,cat: 'storage'} },
                    { field: 'unit', title: '单位', type: 'JSelect', effect: {required: true}, props: {clearable: true, list: []} },
                    {field: 'qty',title: '期初数量',type:'vxe-input',style:'width:100%;',props: {type: 'integer',size: 'small'},effect: {required: true},},
                    {field: 'amount',title: '期初金额',type:'vxe-input',style:'width:100%;',props: {type: 'float',size: 'small',precision: 2},effect: {required: true},}
                ]
            }
        },
        库存统计: {
            fileName: '库存统计',
            allowPage: false,
            sql: `
                select *
                from (select a.tenantId,
                             a.invId,
                             g.name               invName,
                             g.spec,
                             a.locationId,
                             s.name               locationName,
                             a.unit,
                             initC,
                             initP,
                             initM,
                             inC,
                             inM,
                             outC,
                             outM,
                             (initC + inC - outC) lastC,
                             (initM + inM - outM) lastM
                      from (select a.*,
                                   isnull(b.inC, 0)  inC,
                                   isnull(b.inM, 0)  inM,
                                   isnull(b.outC, 0) outC,
                                   isnull(b.outM, 0) outM
                            from (SELECT a.tenantId,
                                         a.locationId,
                                         a.invId,
                                         a.unit,
                                         lastCount           initC,
                                         ROUND(lastPrice, 2) initP,
                                         lastMoney           initM
                                  from (SELECT *
                                        from inventory_detail
                                        where tenantId = $tid and isCal = 1 and billDate < '$beginDate') a
                                           inner join
                                       (SELECT max(seq) seq, tenantId, locationId, invId
                                        from inventory_detail
                                        where tenantId = $tid
                                          and isCal = 1
                                          and billDate < '$beginDate'
                                        GROUP BY tenantId, locationId, invId) b
                                       on a.tenantId = b.tenantId and a.locationId = b.locationId and
                                          a.invId = b.invId and a.seq = b.seq) a
                                     left join
                                 (SELECT tenantId,
                                         locationId,
                                         invId,
                                         sum(inCount)  inC,
                                         sum(inMoney)  inM,
                                         sum(outCount) outC,
                                         sum(costMoney) outM
                                  from inventory_detail
                                  where tenantId = $tid
                                    and isCal = 1
                                    and billDate >= '$beginDate'
                                    and billDate <= '$endDate'
                                  GROUP BY tenantId, locationId, invId) b
                                 on a.tenantId = b.tenantId and a.locationId = b.locationId and a.invId = b.invId) a
                               inner join goods g on a.invId = g.id
                               left join storage s on a.locationId = s.id) a where 1=1 
            `,
            order: '  order by tenantId,locationId,invId,lastC desc  ',
            columns: [
                {type: 'seq', width: 50},
                {field: 'invName', title: '商品名称', width: 300, excel: true,sortable: true,filter: true},
                {field: 'locationName', title: '仓库名称', width: 130, excel: true,sortable: true,filter: true,align: 'center'},
                {field: 'spec', title: '规格', width: 60, excel: true,align: 'center'},
                {field: 'unit', title: '单位', width: 60, excel: true,align: 'center'},
                {title: '期初结存', align: 'center',
                    children:[
                        {field: 'initC', title: '数量', width: 120,excel: true, headerAlign: 'center',align: 'right',sum: true},
                        {field: 'initM', title: '金额', width: 120,excel: true, headerAlign: 'center',align: 'right',sum: true},
                    ]
                },
                {title: '库存新增', align: 'center',
                    children:[
                        {field: 'inC', title: '数量', width: 120,excel: true, headerAlign: 'center',align: 'right',sum: true},
                        {field: 'inM', title: '金额', width: 120,excel: true, headerAlign: 'center',align: 'right',sum: true},
                    ]
                },
                {title: '库存减少（成本）', align: 'center',
                    children:[
                        {field: 'outC', title: '数量', width: 120,excel: true, headerAlign: 'center',align: 'right',sum: true},
                        {field: 'outM', title: '金额', width: 120,excel: true, headerAlign: 'center',align: 'right',sum: true},
                    ]
                },
                {title: '期末结存', align: 'center',
                    children:[
                        {field: 'lastC', title: '数量', width: 120,excel: true, headerAlign: 'center',align: 'right',sum: true},
                        {field: 'lastM', title: '金额', width: 120,excel: true, headerAlign: 'center',align: 'right',sum: true},
                    ]
                },
                {
                    field: 'op', title: '操作', width: 100,align: 'center', slots: {default: 'op'},
                    btns: [
                        {label: '明细',click: (row) => {
                                _this.$emit('getMx', row)
                            }},
                    ]
                },
            ],
            search: {
                rule: [
                    {field: 'range', title: '日期', width: 150, op: " ='$' ",type: 'JPicker', props: {clearable: true, type: 'daterange',width: 220},value: [tools.getDay('', -15), tools.getDay()]},
                    {field: 'invId', title: '商品名称', width: 150, op: " ='$' ",type: 'JSelect',props: {clearable: true, cat: 'goods'}},
                    {field: 'beginDate', op:" >= '$'", type: 'hidden'},
                    {field: 'endDate', op:" <= '$'", type: 'hidden'},
                    { field: 'locationId', title: '仓库名称', type: 'JSelect',  props: {clearable: true,cat: 'storage'} },
                    { field: 'lastC', title: '零库存', type: 'el-checkbox',  props: {trueLabel: 1,falseLabel: 0,title: '包含零库存'} },
                    { field: 'bizC', title: '零发生', type: 'el-checkbox',  props: {trueLabel: 1,falseLabel: 0,title: '包含零发生'},value: 1 },
                ]
            },
            form: {
                mod: 'initGoods',
                rule: [
                ]
            }
        },
        库存明细: {
            fileName: '库存明细',
            allowPage: false,
            sql: `
                select a.isInit,a.billDate,a.transTypeName,a.transType,c.name buName,inCount inC,inPrice inP,inMoney inM,
                       outCount outC,costPrice outP,costMoney outM,lastCount lastC,lastPrice lastP,lastMoney lastM from 
                             (
                                 SELECT  *,0 isInit from inventory_detail where tenantId = $tid and isCal = 1 and locationId=$locationId and invId=$invId and billDate >= '$beginDate' and billDate<='$endDate'
                                 union all
                                 SELECT top 1 *,1 isInit from inventory_detail where tenantId = $tid and isCal = 1 and locationId=$locationId and invId=$invId and billDate < '$beginDate' ORDER BY seq desc
                             ) a 
                left join invoice b on a.iid=b.id left join contact c on b.buId=c.id
            `,
            order: '  order by a.tenantId,a.locationId,a.invId,a.billDate,a.transType',
            columns: [
                {type: 'seq', width: 50},
                // {field: 'invName', title: '商品名称', width: 300, excel: true,sortable: true,filter: true},
                // {field: 'locationName', title: '仓库名称', width: 130, excel: true,sortable: true,filter: true,align: 'center'},
                // {field: 'spec', title: '规格', width: 60, excel: true,align: 'center'},
                {field: 'transTypeName', title: '业务类型', width: 80, excel: true,align: 'center'},
                {field: 'billDate', title: '日期', width: 100, excel: true,align: 'center'},
                {field: 'buName', title: '往来单位', width: 220, excel: true,align: 'left'},
                {title: '库存新增', align: 'center',
                    children:[
                        {field: 'inC', title: '数量', width: 80,excel: true, headerAlign: 'center',align: 'right',sum: true},
                        {field: 'inP', title: '单价', width: 80,excel: true, headerAlign: 'center',align: 'right', },
                        {field: 'inM', title: '金额', width: 100,excel: true, headerAlign: 'center',align: 'right',sum: true},
                    ]
                },
                {title: '库存减少（成本）', align: 'center',
                    children:[
                        {field: 'outC', title: '数量', width: 80,excel: true, headerAlign: 'center',align: 'right',sum: true},
                        {field: 'outP', title: '成本单价', width: 80,excel: true, headerAlign: 'center',align: 'right', },
                        {field: 'outM', title: '金额', width: 100,excel: true, headerAlign: 'center',align: 'right',sum: true},
                    ]
                },
                {title: '期末结存（成本）', align: 'center',
                    children:[
                        {field: 'lastC', title: '数量', width: 80,excel: true, headerAlign: 'center',align: 'right' ,sumIsLast: true},
                        {field: 'lastP', title: '单价', width: 80,excel: true, headerAlign: 'center',align: 'right', },
                        {field: 'lastM', title: '金额', width: 100,excel: true, headerAlign: 'center',align: 'right' ,sumIsLast: true},
                    ]
                },
            ],
            search: {
                rule: [
                    {field: 'range', title: '日期', width: 150, op: " ='$' ",type: 'JPicker', props: {clearable: true, type: 'daterange',width: 220},},
                    {field: 'beginDate', op:" >= '$'", type: 'hidden'},
                    {field: 'endDate', op:" <= '$'", type: 'hidden'},
                    {field: 'locationId', op:" = '$'", type: 'hidden'},
                    {field: 'invId', op:" = '$'", type: 'hidden'},
                ]
            },
            form: {
                mod: 'initGoods',
                rule: []
            }
        },
        车辆: {
            fileName: '车辆',
            allowPage: false,
            sql: `
                select id,licence,name,
                       case when isnull(length,0)=0 then null else length end length,
                       case when isnull(width,0)=0 then null else width end width,
                       case when isnull(height,0)=0 then null else height end height,
                       case when isnull(load,0)=0 then null else load end load
                from cars where tenantId=$tid and isDel=0 
            `,
            order: '  order by name ',
            columns: [
                {type: 'seq', width: 50},
                // {field: 'invName', title: '商品名称', width: 300, excel: true,sortable: true,filter: true},
                // {field: 'locationName', title: '仓库名称', width: 130, excel: true,sortable: true,filter: true,align: 'center'},
                // {field: 'spec', title: '规格', width: 60, excel: true,align: 'center'},
                {field: 'transTypeName', title: '业务类型', width: 80, excel: true,align: 'center'},
                {field: 'billDate', title: '日期', width: 100, excel: true,align: 'center'},
                {field: 'buName', title: '往来单位', width: 220, excel: true,align: 'left'},
                {title: '库存新增', align: 'center',
                    children:[
                        {field: 'inC', title: '数量', width: 80,excel: true, headerAlign: 'center',align: 'right',sum: true},
                        {field: 'inP', title: '单价', width: 80,excel: true, headerAlign: 'center',align: 'right', },
                        {field: 'inM', title: '金额', width: 100,excel: true, headerAlign: 'center',align: 'right',sum: true},
                    ]
                },
                {title: '库存减少（成本）', align: 'center',
                    children:[
                        {field: 'outC', title: '数量', width: 80,excel: true, headerAlign: 'center',align: 'right',sum: true},
                        {field: 'outP', title: '成本单价', width: 80,excel: true, headerAlign: 'center',align: 'right', },
                        {field: 'outM', title: '金额', width: 100,excel: true, headerAlign: 'center',align: 'right',sum: true},
                    ]
                },
                {title: '期末结存（成本）', align: 'center',
                    children:[
                        {field: 'lastC', title: '数量', width: 80,excel: true, headerAlign: 'center',align: 'right' ,sumIsLast: true},
                        {field: 'lastP', title: '单价', width: 80,excel: true, headerAlign: 'center',align: 'right', },
                        {field: 'lastM', title: '金额', width: 100,excel: true, headerAlign: 'center',align: 'right' ,sumIsLast: true},
                    ]
                },
            ],
            search: {
                rule: [
                    {field: 'range', title: '日期', width: 150, op: " ='$' ",type: 'JPicker', props: {clearable: true, type: 'daterange',width: 220},},
                    {field: 'beginDate', op:" >= '$'", type: 'hidden'},
                    {field: 'endDate', op:" <= '$'", type: 'hidden'},
                    {field: 'locationId', op:" = '$'", type: 'hidden'},
                    {field: 'invId', op:" = '$'", type: 'hidden'},
                ]
            },
            form: {
                mod: 'initGoods',
                rule: []
            }
        },
    }
    return cs[whichPage]
}


module.exports = pageParams